//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "aisuppress\fn_endSuppression.sqf"
#include <core_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_unit","_sphere","_idx"];
DEFAULT_PARAM(_unit,0,objNull);

if (!isNull _unit) then {
	_unit setUnitPos "AUTO";
	_unit setUnitPosWeak "AUTO";
	_unit setVariable [QGVAR(UNIT_STATE),0];
	_unit setVariable [QGVAR(SEARCH_COVER),-1];
	_sphere = _unit getVariable [QGVAR(DEBUG_SPHERE),objNull];
	if (!isNull _sphere) then {
		TRACE_1("Deleting Sphere",_sphere);
		detach _sphere;
		deleteVehicle _sphere;
		_unit setVariable [QGVAR(DEBUG_SPHERE),objNull,true];
	};
	_idx = _unit getVariable [QGVAR(DEBUG_SPHERE_EVT),-1];
	if (_idx > 0) then {
		_unit removeEventHandler ["killed",_idx];
		_unit setVariable [QGVAR(DEBUG_SPHERE_EVT),-1];
	};
	_idx = _unit getVariable [QGVAR(FIRED_EVT),-1];
	if (_idx > 0) then {
		_unit removeEventHandler ["fired",_idx];
		_unit setVariable [QGVAR(FIRED_EVT),-1];
	};
};

TRACE("End");
TMFPROFILERSTOP;
